package com.tledu.springboot04.controlller;

import com.tledu.springboot04.constants.CommonConstans;
import com.tledu.springboot04.domain.Resources;
import com.tledu.springboot04.service.ResourcesService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

/**
 * @author Antg
 * @date 2021/8/25  18:28
 */
@Controller
@AllArgsConstructor
public class CommonController {
    private final ResourcesService resourcesService;

    @GetMapping(value = {"/", "/index"})
    public String index(Model model) {
        List<Resources> list = resourcesService.list();
        model.addAttribute(CommonConstans.MENU, list);
        return "index";
    }

    @GetMapping("/welcome")
    public String welcome() {
        return "welcome";
    }

}
